<template>
  <div class="newsinfo-container">
    <h3 class="title">{{newsInfo.title}}</h3>
    <p class="subtitle">
      <span>{{newsInfo.add_time | dateFormat}}</span>
      <span>点击{{newsInfo.click}}次</span>
    </p>
    <hr>
    <div class="content" v-html="newsInfo.content"></div>

    <commentBox :id="this.id"></commentBox>
  </div>
</template>

<script>
  //引入评论子组件
  import commentBox from '../subcomponents/Comments.vue'
  export default {
    data() {
      return {
        id: this.$route.params.id,
        newsInfo: {}
      }
    },
    created(){
      this.getnewsInfo()
    },
    methods: {
      getnewsInfo() {//获取新闻详情信息
        this.$http.get('api/getnew/'+ this.id).then(result => {
          if (result.body.status === 0) {
            this.newsInfo = result.body.message[0]
          } else {

          }
        })
      }
    },
    components:{
      'commentBox':commentBox
    }
  }
</script>

<style scoped lang="scss">
  .newsinfo-container {
    padding: 0 4px;
    .title {
      font-size: 16px;
      text-align: center;
      color: red;
      margin: 15px 0;
    }

    .subtitle {
      font-size: 13px;
      display: flex;
      justify-content: space-between;
      color: #226aff;
    }
    .content{
      image{
        width: 100%;
      }
    }
  }

</style>